package com.edu.exam.enums.operations;

import com.edu.exam.enums.core.BaseEnum;

/**
 * 批量操作类型枚举
 *
 * 管理批量操作的类型分类，包括批量创建、更新、删除、导入、导出等操作类型
 *
 * @author System
 * @version 1.0.0
 */
public enum BatchOperationType implements BaseEnum {

    /**
     * 批量创建
     */
    BATCH_CREATE("BATCH_CREATE", "批量创建"),

    /**
     * 批量更新
     */
    BATCH_UPDATE("BATCH_UPDATE", "批量更新"),

    /**
     * 批量删除
     */
    BATCH_DELETE("BATCH_DELETE", "批量删除"),

    /**
     * 批量导入
     */
    BATCH_IMPORT("BATCH_IMPORT", "批量导入"),

    /**
     * 批量导出
     */
    BATCH_EXPORT("BATCH_EXPORT", "批量导出"),

    /**
     * 批量状态变更
     */
    BATCH_STATUS_CHANGE("BATCH_STATUS_CHANGE", "批量状态变更"),

    /**
     * 批量分类分配
     */
    BATCH_CATEGORY_ASSIGN("BATCH_CATEGORY_ASSIGN", "批量分类分配"),

    /**
     * 批量标签分配
     */
    BATCH_TAG_ASSIGN("BATCH_TAG_ASSIGN", "批量标签分配");

    private final String code;
    private final String description;

    BatchOperationType(String code, String description) {
        this.code = code;
        this.description = description;
    }

    @Override
    public String getCode() {
        return code;
    }

    @Override
    public String getDescription() {
        return description;
    }

    /**
     * 从代码创建枚举实例
     *
     * @param code 枚举代码
     * @return 对应的枚举实例
     */
    public static BatchOperationType fromCode(String code) {
        for (BatchOperationType type : values()) {
            if (type.getCode().equals(code)) {
                return type;
            }
        }
        throw new IllegalArgumentException("Unknown batch operation type code: " + code);
    }

    /**
     * 从描述创建枚举实例
     *
     * @param description 枚举描述
     * @return 对应的枚举实例
     */
    public static BatchOperationType fromDescription(String description) {
        for (BatchOperationType type : values()) {
            if (type.getDescription().equals(description)) {
                return type;
            }
        }
        throw new IllegalArgumentException("Unknown batch operation type description: " + description);
    }

    @Override
    public String toString() {
        return description;
    }
}